import { messageDuration } from '@/config'

import { ElMessage, ElNotification } from 'element-plus'

const duration = messageDuration * 1000

/**
 * @description 消息提示
 * @param msg
 */
const message = (msg) => {
  ElMessage({
    message: msg,
    type: 'info',
    showClose: true,
    duration: duration,
  })
}

/**
 * @description 成功提示
 * @param msg
 */
message.success = (msg) => {
  ElMessage({
    message: msg,
    type: 'success',
    showClose: true,
    duration: duration,
  })
}

/**
 * @description 错误提示
 * @param msg
 */
message.error = (msg) => {
  ElMessage({
    message: msg,
    type: 'error',
    showClose: true,
    duration: duration,
  })
}

/**
 * @description 警告提示
 * @param msg
 */
message.warn = (msg) => {
  ElMessage({
    message: msg,
    type: 'warning',
    showClose: true,
    duration: duration,
  })
}

/**
 * @description Notification通知
 * @param title 标题
 * @param msg 消息
 */
const notification = (title, msg) => {
  ElNotification({
    title: title,
    message: msg,
    type: 'info',
    duration: duration,
  })
}

/**
 * @description Notification成功通知
 * @param title 标题
 * @param msg 消息
 */
notification.success = (title, msg) => {
  ElNotification({
    title: title,
    message: msg,
    type: 'success',
    duration: duration,
  })
}

/**
 * @description Notification错误通知
 * @param title 标题
 * @param msg 消息
 */
notification.error = (title, msg) => {
  ElNotification({
    title: title,
    message: msg,
    type: 'error',
    duration: duration,
  })
}

/**
 * @description Notification警告通知
 * @param title 标题
 * @param msg 消息
 */
notification.warn = (title, msg) => {
  ElNotification({
    title: title,
    message: msg,
    type: 'warning',
    duration: duration,
  })
}

export { message, notification }
